]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
log(): Reimplement on top of GLib.log_structured
authorJonh Wendell <jonh.wendell@redhat.com>
Mon, 3 Oct 2016 23:09:39 +0000 (20:09 -0300)
committerJonh Wendell <jonh.wendell@redhat.com>
Tue, 11 Oct 2016 13:17:12 +0000 (10:17 -0300)
This allows us to pass metadata fields besides the message
to log. So, if the log() call is made from an extension,
pass the extension name and UUID to the logger.

This is useful for extension developers to debug their code
as well as to instruct their users to send debug info to them
by running something like this:

journalctl GNOME_SHELL_EXTENSION_UUID=<extension@uuid>

https://bugzilla.gnome.org/show_bug.cgi?id=770717

configure.ac
js/ui/environment.js

index 7d47643f515f1268f213465ea3a55f816b4aa330..b436a86526ff887380ada6170ad84d527f0549de 100644 (file)
@@ -77,7 +77,7 @@ AC_MSG_RESULT($enable_systemd)
 
 CLUTTER_MIN_VERSION=1.21.5
 GOBJECT_INTROSPECTION_MIN_VERSION=1.49.1
-GJS_MIN_VERSION=1.39.0
+GJS_MIN_VERSION=1.47.0
 MUTTER_MIN_VERSION=3.22.1
 GTK_MIN_VERSION=3.15.0
 GIO_MIN_VERSION=2.45.3
index 6fb23e3534763f42e312148c0a71a0848499719b..68ddaa783017b31b060e0b00e74b685df8c2c4af 100644 (file)
@@ -61,10 +61,19 @@ function _patchLayoutClass(layoutClass, styleProps) {
     };
 }
 
-function _makeLoggingFunc(func) {
-    return function() {
-        return func([].join.call(arguments, ', '));
-    };
+function _loggingFunc() {
+    let fields = {'MESSAGE': [].join.call(arguments, ', ')};
+    let domain = "GNOME Shell";
+
+    // If the caller is an extension, add it as metadata
+    let extension = imports.misc.extensionUtils.getCurrentExtension();
+    if (extension != null) {
+        domain = extension.metadata.name;
+        fields['GNOME_SHELL_EXTENSION_UUID'] = extension.uuid;
+        fields['GNOME_SHELL_EXTENSION_NAME'] = extension.metadata.name;
+    }
+
+    GLib.log_structured(domain, GLib.LogLevelFlags.LEVEL_MESSAGE, fields);
 }
 
 function init() {
@@ -72,7 +81,7 @@ function init() {
     // browser convention of having that namespace be called 'window'.)
     window.global = Shell.Global.get();
 
-    window.log = _makeLoggingFunc(window.log);
+    window.log = _loggingFunc;
 
     window._ = Gettext.gettext;
     window.C_ = Gettext.pgettext;